﻿using System.Linq;
using Iot.AlarmDispose.Database.Entities;

namespace Iot.AlarmDispose.Database;

public static class DbHelp
{
    /// <summary>
    ///     获取没有软删除的数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="db"></param>
    /// <returns></returns>
    public static IQueryable<T> GetNotSoftDelete<T>(this IQueryable<T> db) where T : class, ISoftDelete
    {
        return db.Where(static a => a.IsDeleted == false);
    }

    /// <summary>
    ///     获取软删除的数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="db"></param>
    /// <returns></returns>
    public static IQueryable<T> GetSoftDelete<T>(this IQueryable<T> db) where T : class, ISoftDelete
    {
        return db.Where(static a => a.IsDeleted == true);
    }
}